package cn.kgc.service;

import cn.kgc.mapper.BillMapper;
import cn.kgc.pojo.Bill;
import cn.kgc.util.PageBean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author 蒿雨
 * @create 2021-11-04 14:35
 */
@Service("bsi")
public class BillServiceImpl implements BillService {
    @Resource
    BillMapper billMapper;

    @Override
    public int getTotalCount(Map<String, Object> map) {
        return billMapper.getCount(map);
    }

    @Override
    public PageBean<Bill> getList(Map<String, Object> map) {
        PageBean<Bill> pageBean = new PageBean<>();
        pageBean.setPageSize((int) map.get("pageSize"));
        pageBean.setCurrentPage((int) map.get("startIndex"));
        pageBean.setTotalCount(billMapper.getCount(map));
        map.put("startIndex", pageBean.getStartIndex());
        pageBean.setResult(billMapper.billSelect(map));
        return pageBean;
    }

    @Override
    public boolean addB(Bill bill) {
        if (billMapper.addB(bill) > 0) {
            return true;
        }
        return false;
    }

    @Override
    public Bill getB(int id) {
        return billMapper.getB(id);
    }

    @Override
    public boolean isFull(int id) {
        System.out.println("结果为"+billMapper.isFull(id));
        if (billMapper.isFull(id) <= 0) {

            return true;
        }
        return false;
    }

    @Override
    public int deleteB(int id) {
        return billMapper.deleteB(id);
    }

    @Override
    public boolean billModify(Bill bill) {
        if (billMapper.billModify(bill) > 0) {
            return true;
        }
        return false;
    }
}
